/*
 * \brief  Client-side IRQ session interface
 * \author Christian Helmuth
 * \date   2007-09-13
 */

/*
 * Copyright (C) 2007-2009 Christian Helmuth
 * Genode Labs, Feske & Helmuth Systementwicklung GbR
 *
 * This file is part of the Genode OS framework, which is distributed
 * under the terms of the GNU General Public License version 2.
 */

#ifndef _INCLUDE__IRQ_SESSION__CLIENT_H_
#define _INCLUDE__IRQ_SESSION__CLIENT_H_

#include <irq_session/capability.h>
#include <base/ipc.h>
#include <base/lock_guard.h>

namespace Genode {

	class Irq_session_client : public Irq_session
	{
		private:

			Msgbuf<32> _snd_msg, _rcv_msg;
			Ipc_client _ipc_client;
			Lock       _lock;

		public:

			/**
			 * Constructor
			 */
			Irq_session_client(Irq_session_capability session)
			: _ipc_client(session, &_snd_msg, &_rcv_msg) { }


			/***************************
			 ** IRQ session interface **
			 ***************************/

			void wait_for_irq()
			{
				Lock::Guard lock_guard(_lock);

				_ipc_client << WAIT_FOR_IRQ << IPC_CALL;
			}
	};
}

#endif /* _INCLUDE__IRQ_SESSION__CLIENT_H_ */
